package com.lincong.demo.pojo;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * @author linchong
 * @version 1.0
 * @Date: 2022-07-04 22:36
 * @Description: Handler$
 */

/**
 * 封装handler方法相关的信息
 */
public class Handler {

	//method.invoke(obj,parameter)
	private Object controller;

	private Method method;

	//spring中url是支持正则的
	private Pattern pattern;

	//存储参数顺序
	private Map<String,Integer> paramIndexMapping;

	public Object getController() {
		return controller;
	}

	public void setController(Object controller) {
		this.controller = controller;
	}

	public Handler(Object controller, Method method, Pattern pattern) {
		this.controller = controller;
		this.method = method;
		this.pattern = pattern;
		this.paramIndexMapping = new HashMap<>();
	}

	public Method getMethod() {
		return method;
	}

	public void setMethod(Method method) {
		this.method = method;
	}

	public Pattern getPattern() {
		return pattern;
	}

	public void setPattern(Pattern pattern) {
		this.pattern = pattern;
	}

	public Map<String, Integer> getParamIndexMapping() {
		return paramIndexMapping;
	}

	public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
		this.paramIndexMapping = paramIndexMapping;
	}
}
